Skip to content

feat: save input text draft into local storage#9809

Open
uinstinct wants to merge 8 commits intocontinuedev:mainfrom
uinstinct:save-input-text
Open

feat: save input text draft into local storage#9809
uinstinct wants to merge 8 commits intocontinuedev:mainfrom
uinstinct:save-input-text

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Jan 23, 2026

Description

Save the unsubmitted input text into local storage so that it persists between reloads and page changes.

resolves CON-5281

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

before.mp4
after.mp4

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Continue Tasks: ▶️ 2 queued — View all


Summary by cubic

Persist main input drafts across reloads and navigation. Save per-message edit drafts with scroll and focus restore within a session; they clear on app unmount (CON-5281).

  • New Features

    • Save main input as JSON under inputDraft_; save per-message edit under editingDraft_ with content, messageId, and scrollTop.
    • Load saved drafts into the main input and matching message editor; restore scroll and focus when returning.
    • Clear drafts on submit, when empty, when switching between main input and edits, and clear per-message drafts on app unmount.
    • Added localStorage types for inputDraft_ and editingDraft_.
  • Refactors

    • Removed the clearContent effect in TipTapEditor to prevent wiping drafts on mount.

Written for commit dde7a97. Summary will update on new commits.

@uinstinct uinstinct requested a review from a team as a code owner January 23, 2026 05:46
@uinstinct uinstinct requested review from sestinj and removed request for a team January 23, 2026 05:46
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jan 23, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uinstinct it looks like this only works for the main input. I think it's an improvement but can we think of a simple way to have this work across conversations and in any tip tap editor when going to settings and back?

  1. On closing/reopening vs code it's okay to lose drafts in any editor but would be nice if main editor was saved (already works on this branch) and great if all were saved (in a way that doesn't leak local storage etc memory)
  2. On going to settings and back any editor's content is preserved, as well as the scroll position of the chat history in case I was editing message number 2 in a 5 message sequence

If too many tradeoffs we can merge this but let's brainstorm on full solution first. There might be a simple solution where we don't unmount the component at all when switching to settings (router level fix).

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Feb 4, 2026
@uinstinct
Copy link
Contributor Author

  1. On closing/reopening vs code it's okay to lose drafts in any editor but would be nice if main editor was saved (already works on this branch) and great if all were saved (in a way that doesn't leak local storage etc memory)

It currently saves all - there would not be any memory leakage, as far as I think, because there can only be 2 drafts be saved: inputDraft_chat or inputDraft_edit which get cleared during submission

  1. On going to settings and back any editor's content is preserved, as well as the scroll position of the chat history in case I was editing message number 2 in a 5 message sequence

I did a simple implementation for this to save the editing draft and scroll back to chat history position.

feat.mp4

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uinstinct I think with the positioned draft approach if the draft is not submitted and a main input message is submitted instead it will not clear the other draft so the UI will glitch around, including if you started up vs code it would "glitch" to the input draft even if it was outdated

}
} else {
if (hasValidEditorContent(content)) {
const scrollContainer = document.querySelector(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use a more robust way to get the scroll container e.g. id or non generic class

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 6, 2026
@uinstinct
Copy link
Contributor Author

@uinstinct I think with the positioned draft approach if the draft is not submitted and a main input message is submitted instead it will not clear the other draft so the UI will glitch around, including if you started up vs code it would "glitch" to the input draft even if it was outdated

Added removing of both drafts (editing and main input) after submission and gui window unmount.

@uinstinct uinstinct requested a review from RomneyDa February 6, 2026 04:03
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="gui/src/hooks/ParallelListeners.tsx">

<violation number="1" location="gui/src/hooks/ParallelListeners.tsx:270">
P2: The cleanup-only useEffect has no dependency array, so it runs after every render and clears draft keys on each re-render. Because this component re-renders from Redux state updates, saved drafts are repeatedly deleted, undermining persistence. Add a dependency array (or otherwise scope cleanup) so it only runs on unmount if that’s the intent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="gui/src/hooks/ParallelListeners.tsx">

<violation number="1" location="gui/src/hooks/ParallelListeners.tsx:275">
P2: Cleaning localStorage drafts on ParallelListeners unmount undermines draft persistence and can wipe drafts in Strict Mode remounts or when the root component is disposed.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants